// 思路：将要改变this指向的方法挂到目标this上执行并返回
/**
 * defCall(this,...arg)
 * @param target
 * @returns {*}
 */
Function.prototype.defCall = function(target){
    if(typeof this !== 'function'){
        throw new TypeError('not function')
    }
    target = target || window
    target.fn = this
    //第一个是this,后面的才是参数
    let arg = [...arguments].slice(1)
    let result = target.fn(...arg)
    delete target.fn
    return result
}


function log(){
    console.log.defCall(this,...arguments)
}

log([1,2,3].slice(1),2)